home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: Locaton of an array?
- Date: 24 Jan 1996 08:16:48 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4e5m1gINNeh5@keats.ugrad.cs.ubc.ca>
- References: <4d4iqk$hs3@overload.lbl.gov> <4d698s$g4r@news.iag.net> <4d6nd7$4gg@overload.lbl.gov>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <4d6nd7$4gg@overload.lbl.gov>,
- Mikhail Faiguenblat <mfaiguen@issserv4.lbl.gov> wrote:
- >Tanmoy Bhattacharya (tanmoy@qcd.lanl.gov) wrote:
- >[stuff deleted]
- >: Btw, just out of curiosity, why do you care where it lives in
- >: absolute RAM?
- >
- >I just posted the description of the problem.
- >Also, if anyone has written or knows of a C program that uses DMA, how did
- >you deal with the issue of having to specify the physical addresses (I do not
- >know if that is the issue for other processors, but for x86 it is).
- >
- >: By the way, the output of %p (as also the result of the (int) cast on
- >: a pointer) is upto the implementation. C can be implemented on machines
- >: which have no natural mapping onto a flat address space, so the
- >: original question may not have a definite meaning. An answer to the
- >: `why' that you ask is definitely required before more help can be
- >: provided.
- >
- >Ok, so C works with virtual addresses, and all the registers (such as
- >segment register, offset register, etc.) also store virtual addresses.
- >Also, a program when being executed writes to and reads from real memory.
- >This means that somewhere there is a virtual memory mamnager (?) which
- >keeps track of which segment of virtual memory corresponds to which
- >segment of real memory.
- >Is it done on kernel level?
-
- Yes and no. The kernel keeps track of free pages, and adds/removes them to the
- page directories of processes as needed.
-
- However, the translation from virtual to physical addresses is done by the CPU
- hardware. The CPU knows the physical address of the page directory---it has a
- special register that tells it where to find it. As an important optimization,
- the CPU stores recently looked-up translations in a special buffer called the
- translation lookaside buffer (or virtual address translation cache, if you
- don't like IBM terminology) so it doesn't have to walk the page directory for
- every memory reference. Without the buffer, the system would run like an utter
- dog.
-
- So, the CPU implements the address translation and the means to catch accesses
- to protected or not-present pages with special exceptions. The kernel manages
- the allocation of pages to page directories, the swapping of pages to and from
- disk, and so forth.
-
- If you want to access some hardware locations directly from a user processe,
- you have to request a mapping from the OS, which will "nail" the device's
- memory aperture to some range of virtual addresses that will then be accessible
- to your process.
- --
-
-